# -*- coding: utf-8 -*-
"""
@Time ： 2024/1/6 0006 16:36
@Auth ： ysc
@File ：pipeline_page.py
@IDE ：PyCharm
"""
import time
from Page.base_page import BasePage
from Page.login_page import LoginPage
from Lib.readelement import Element
from Lib.log import log

pipeline = Element('pipeline')


class ImageBuildPage(BasePage):
    """流水线页面"""
    repo_url = None
    os_name = None
    version = None
    release = None

    os_name_ib = None
    kernel_param = None
    repo_url_ib = None

    def login(self, url=None, name=None, password=None):
        """
        用户登录
        """
        login = LoginPage(self.driver)
        login.login(url, name, password)

    def pipeline_delete_button(self):
        """流水线删除按钮"""
        try:
            self.click(pipeline["delete_button"])
        except Exception as e:
            log.error("error: found delete_button timeout")
            log.info(e)

    def pipeline_alert_cancel(self):
        """
        流水线删除弹窗取消按钮
        """
        try:
            self.click(pipeline["alert_cancel"])
        except Exception as e:
            log.error("error: found alert_cancel timeout")
            log.info(e)

    def pipeline_alert_close(self):
        """
        流水线弹窗关闭按钮
        """
        try:
            self.click(pipeline["alert_close"])
        except Exception as e:
            log.error("error: found alert_close timeout")
            log.info(e)

    def select_first_pipeline(self):
        """
        选择流水线列表第一条
        """
        try:
            self.click(pipeline["first_pipeline_group"])
        except Exception as e:
            log.error("error: found pipeline_button timeout")
            log.info(e)
